<?php

namespace app\common\model;

use think\Model;


class Photo extends Model
{

    

    

    // 表名
    protected $name = 'photo';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'images_array',
    ];
    

    public function getImageAttr($value, $data)
    {
        if ($value) {
            return cdnurl($value, true);
        }
        return '';
    }
    public function getImagesArrayAttr($value, $data)
    {
        if ($data['images']) {
            $array = explode(',', $data['images']);
            foreach ($array as &$v) {
                $v = cdnurl($v, true);
            }
            return $array;
        }
        return [];
    }







}
